package net.sky.oa.dao.ioffice.impl;

import java.util.List;
import java.util.ArrayList;

import org.springframework.stereotype.Repository;

import net.sky.oa.model.OffTaskUser;
import net.sky.oa.dao.SkyBaseDaoImpl;
import net.sky.oa.dao.ioffice.OffTaskUserDao;
@SuppressWarnings("unchecked")
@Repository
public class OffTaskUserDaoImpl extends SkyBaseDaoImpl<OffTaskUser> implements OffTaskUserDao {

	public List<OffTaskUser> findByUserIdorSummId(Long userId, Long taskId) {
		StringBuilder hql=new StringBuilder("from OffTaskUser tu where 1=1 ");
		List list=new ArrayList();
		if(userId!=-1)
		{
			hql.append(" and tu.rusr.id=?");
			list.add(userId);
		}
		if(taskId!=-1)
		{
			hql.append(" and tu.task.id=?");
			list.add(taskId);
		}
		return findByHql(hql.toString(), list.toArray());
	}

}
